import {
  Module,
  Inject,
  NestModule,
  MiddlewareConsumer,
  RequestMethod,
} from '@nestjs/common'

// 中间件
import { LoggerMiddleware } from './logger.middleware'
import { Logger2Middleware } from './logger2.middleware'

// 模块

// 控制器
import { AppController } from './app.controller'

// 提供者
import { AppService } from './app.service'


@Module({
  // 模块
  imports: [
  ],
  // 控制器
  controllers: [
    AppController,
  ],
  // 提供者 ( 服务 )
  providers: [
    AppService,
  ]
})
export class AppModule implements NestModule {
  configure(consumer: MiddlewareConsumer) {
    consumer
      .apply(LoggerMiddleware)
      // .forRoutes({path: '/', method: RequestMethod.ALL}, {path: '/user/*', method: RequestMethod.ALL})
      .exclude('/user') // 排除在 AppController 控制器中的 '/user' 路径
      .forRoutes(AppController)
  }
}

